package com.atguigu.gmall.search.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.search.Goods;
import com.atguigu.gmall.search.repository.GoodsRepository;
import com.atguigu.gmall.search.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/api/inner/search")
@RestController
public class SearchRpcController {

    @Autowired
    GoodsService goodsService;

//    上架
//    将商品数据保存到es中
    @PostMapping("/save")
    public Result saveGoods(@RequestBody Goods goods){

        goodsService.save(goods);
        return Result.ok();
    }

//    下架
    @DeleteMapping("/goods/{skuId}")
    public Result delete(@PathVariable("skuId") Long skuId){
        goodsService.deleteById(skuId);
        return Result.ok();
    }

}
